package com.qzsoft.zhjd.materiel.modules.materielproject.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzsoft.zhjd.materiel.modules.materielproject.entity.MaterielProjectItemEntity;
import com.qzsoft.zhjd.materiel.modules.materielproject.mapper.MaterielProjectItemMapper;
import com.qzsoft.zhjd.materiel.modules.materielproject.service.MaterielProjectItemService;

/**
 * @ClassName MaterielProjectItemServiceImpl
 * @Description 项目信息业务接口实现
 * @author linhuawei
 * @since 2022-03-30
 */
@Service
public class MaterielProjectItemServiceImpl extends ServiceImpl<MaterielProjectItemMapper, MaterielProjectItemEntity>
        implements MaterielProjectItemService {

    @Override
    public List<MaterielProjectItemEntity> listByProjectId(String projectId) {
        QueryWrapper<MaterielProjectItemEntity> queryWrapper = new QueryWrapper<MaterielProjectItemEntity>();
        queryWrapper.eq("project_id", projectId);
        queryWrapper.orderByDesc("num");
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteByProjectId(Serializable projectId) {
        QueryWrapper<MaterielProjectItemEntity> queryWrapper = new QueryWrapper<MaterielProjectItemEntity>();
        queryWrapper.eq("project_id", projectId);
        baseMapper.delete(queryWrapper);
    }

}
